#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << ": " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(int x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define ru(i,l,r) for(int i=(l);i<(r);i++)
#define ru_(i,l,r) for(int i=(l);i<=(r);i++)

using namespace std;


// 两个长度为1e6,的字符串相互转换
struct g_24_6{ //string: re -> fft
    static const ll N=(1<<11)+5, Mod=2013265921,G=31;
    ll n = 0, m = 0, a[3][N] = {}, b[3][N] = {}, c[N] = {}, d[N] = {};
    char s[N] = {}, t[N] = {};
    ll p[N]={},w[N]={},g[N]={},iv[N]={};
    inline ll power(ll x,ll y){
        ll ret=1; while(y){if(y&1)ret=ret*x%Mod; x=x*x%Mod, y>>=1;}; return ret;
    }
    inline void dft(ll n,ll a[],bool idft){
        for(ll i=0;i<n;i++)if(i<p[i])swap(a[i],a[p[i]]);
        for(ll m=1;m<n;m<<=1)
            for(ll j=0,k=0;j<n;j+=m<<1,k++)
                for(ll i=j;i<j+m;i++){
                    ll x=a[i],y=a[i+m]; a[i]=x+y,a[i]>=Mod&&(a[i]-=Mod);
                    a[i+m]=(x+y+Mod)*w[k]%Mod;
                }
        if(!idft)return;
        reverse(a+1,a+n);
        ru(i,0,n)a[i]=a[i]*iv[n]%Mod;
    }
    inline ll sqr(ll x){return x*x;}
    inline ll work(ll L, ll R, ll l, ll r){
        ll M = 1; while(M < R - L + r - l) M <<= 1;
        w[0] = 1;
        for(ll k = 1 ; k < M ; k <<= 1){
            ll bit = M / 2 / k;
            if(k == M / 2) for(ll i = 0; i < k ; i ++) p[i + k] = p[i] | bit;
            else for(ll i = 0 ; i < k ; i ++){
                    w[i + k] = w[i] * g[k] % Mod;
                    p[i + k] = p[i] | bit;
                }
        }
        for(ll i = 0 ; i < M ; i ++){
            p[i] = p[i >> 1] >> 1;
            if(i & 1) p[i] |= M >> 1;
        }
        ll z = 0;
        for(ll i = 0 ; i < M ; i ++){
            c[i] = 0;
            for(ll f = 0 ; f < 3 ; f ++)  a[f][i] = b[f][i] = 0;
        }
        for(ll i = L ; i < R ; i ++){
            ll x = (s[i] == '-') ? 0 : (s[i] - 'a' + 1);
            a[0][i - L] = x ? 0 : 1, a[1][i - L] = 2 * x, a[2][i - L] = sqr(x), d[i] = sqr(x);
        }
        d[R] = 0;
        for(ll i = l ; i < r ; i ++){
            ll x = (t[i] == '-') ? 0 : (t[i] - 'a' + 1);
            b[0][r - i] = sqr(x), b[1][r - i] = x, b[2][r - i] = x ? 0 : 1, z += sqr(x);
        }
        for(ll f = 0 ; f < 3 ; f ++){
            dft(M, a[f], 0), dft(M, b[f], 0);
            for(ll i = 0 ; i < M ; i ++) c[i] = (c[i] + a[f][i] * b[f][i]) % Mod;
        }
        dft(M, c, 1);
        for(ll i = 0 ; i < r - l ; i ++) z += d[i + L];
        for(ll i = L ; i <= R - (r - l) ; z -= d[i], z += d[i + (r - l)], i ++) if(z % Mod == c[i - L + r - l]) return i;
        return -1;
    }
    int main(){
        for(ll i = 1 ; i < N ; i <<= 1) g[i] = power(G, Mod / 4 / i), iv[i] = power(i, Mod - 2);
        scanf("%lld %lld", &n, &m);
        scanf("%s %s", s, t);
        while(n && m && s[n - 1] != '*' && t[m - 1] != '*'){
            if(s[n - 1] != t[m - 1] && s[n - 1] != '-' && t[m - 1] != '-'){
                printf("No");
                return 0;
            }
            else n --, m --;
        }
        reverse(s, s + n), reverse(t, t + m);
        while(n && m && s[n - 1] != '*' && t[m - 1] != '*'){
            if(s[n - 1] != t[m - 1] && s[n - 1] != '-' && t[m - 1] != '-'){
                printf("No");
                return 0;
            }
            else n --, m --;
        }
        reverse(s, s + n), reverse(t, t + m);
        if(min(n, m) == 0){
            while(n && s[n - 1] == '*') n --;
            while(m && t[m - 1] == '*') m --;
            if(max(n, m) == 0) printf("Yes");
            else printf("No");
            return 0;
        }
        bool u = 0, v = 0;
        for(ll i = 0 ; i < n ; i ++) if(s[i] == '*') u = 1;
        for(ll i = 0 ; i < m ; i ++) if(t[i] == '*') v = 1;
        if(u){
            if(v){
                printf("Yes");
                return 0;
            }
            else swap(n, m), swap(s, t);
        }
        ll L = 0, R = 0;
        for(ll l = 1, r = l ; l < m ; l = r + 1, r = l){
            while(t[r] != '*') r ++;
            if(r - l) while(1){
                    R = min(n, L + 2 * (r - l));
                    if(R - L < r - l){
                        printf("No");
                        return 0;
                    }
                    ll h = work(L, R, l, r);
                    if(h == -1) L = R - (r - l) + 1;
                    else{
                        L = h + r - l;
                        break;
                    }
                }
        }
        printf("Yes");
        return 0;
    }
};

// 长度为1e5,符合要求的二进制子串计数：0或1出现超过一般长度
struct i_24_9{

    const int MOD=998244353;

    ll qexp(ll b,ll p,int m){
        ll res=1;
        while (p){
            if (p&1) res=(res*b)%m;
            b=(b*b)%m;
            p>>=1;
        }
        return res;
    }

    ll inv(ll i){
        return qexp(i,MOD-2,MOD);
    }

    ll fix(ll i){
        i%=MOD;
        if (i<0) i+=MOD;
        return i;
    }

    ll fac[1000005];
    ll ifac[1000005];

    ll nCk(int i,int j){
        if (i<j) return 0;
        return fac[i]*ifac[j]%MOD*ifac[i-j]%MOD;
    }

    const ll mod = (119 << 23) + 1, root = 62; // = 998244353
// For p < 2^30 there is also e.g. 5 << 25, 7 << 26, 479 << 21
// and 483 << 21 (same root). The last two are > 10^9.
    typedef vector<ll> vl;
    void ntt(vl &a) {
        int n = sz(a), L = 31 - __builtin_clz(n);
        static vl rt(2, 1);
        for (static int k = 2, s = 2; k < n; k *= 2, s++) {
            rt.resize(n);
            ll z[] = {1, qexp(root, mod >> s, mod)};
            rep(i,k,2*k) rt[i] = rt[i / 2] * z[i & 1] % mod;
        }
        vector<int> rev(n);
        rep(i,0,n) rev[i] = (rev[i / 2] | (i & 1) << L) / 2;
        rep(i,0,n) if (i < rev[i]) swap(a[i], a[rev[i]]);
        for (int k = 1; k < n; k *= 2)
            for (int i = 0; i < n; i += 2 * k) rep(j,0,k) {
            ll z = rt[j + k] * a[i + j + k] % mod, &ai = a[i + j];
            a[i + j + k] = ai - z + (z > ai ? mod : 0);
            ai += (ai + z >= mod ? z - mod : z);
        }
    }
    vl conv(const vl &a, const vl &b) {
        if (a.empty() || b.empty()) return {};
        int s = sz(a) + sz(b) - 1, B = 32 - __builtin_clz(s), n = 1 << B;
        int inv = qexp(n, mod - 2, mod);
        vl L(a), R(b), out(n);
        L.resize(n), R.resize(n);
        ntt(L), ntt(R);
        rep(i,0,n) out[-i & (n - 1)] = (ll)L[i] * R[i] % mod * inv % mod;
        ntt(out);
        return {out.begin(), out.begin() + s};
    }

    int n;
    string s;

    int c[100005];
    int f[100005];

    void calc(int l,int r,vector<int> v){
        while (sz(v)>(r-l)*2+1) v.pob();

        if (l==r){
            f[l]=v[0];
            return;
        }

        int m=l+r>>1;

        calc(l,m,vector<int>(v.begin()+(r-m),v.end()));
        vector<int> a;
        int t=m-l+1;
        rep(x,0,t+1) a.pub(nCk(t,x)),a.pub(0);

        v=conv(v,a);
        calc(m+1,r,vector<int>(v.begin()+(2*t),v.end()));
    }

    int ans[100005];

    void solve(int l,int r){
        if (l==r) return;
        int m=l+r>>1;
        solve(l,m);
        auto a=conv(vector<int>(ans+l,ans+m+1),vector<int>(f,f+(r-l)));
        rep(x,m+1,r+1) if (s[x]=='0') ans[x]=fix(ans[x]-a[x-1-l]);
        solve(m+1,r);
    }


    signed main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cin.exceptions(ios::badbit | ios::failbit);

        fac[0]=1;
        rep(x,1,1000005) fac[x]=fac[x-1]*x%MOD;
        ifac[1000004]=inv(fac[1000004]);
        rep(x,1000005,1) ifac[x-1]=ifac[x]*x%MOD;

        rep(x,1,100005){
            c[x]++;

            int curr=x;
            while (curr<100005){
                if (curr+2<100005) c[curr+2]-=2;
                if (curr+4<100005) c[curr+4]++;
                if (curr+2*x+4<100005) c[curr+2*x+4]++;
                curr+=2*x+4;
            }
        }

        cin>>n;
        cin>>s;

        vector<int> v;
        rep(x,n+1,1) v.pub(fix(c[x]+(x>=2?c[x-2]:0LL)));
        calc(1,n,v);
        f[0]=1;

        int fin=qexp(2,n,MOD);
        rep(_,0,2){
            rep(x,0,n) ans[x]=(s[x]=='0')?nCk(x,x/2):0LL;
            solve(0,n-1);
            rep(x,0,n) if (s[x]=='0') fin=fix(fin-ans[x]*nCk((n-x-1),(n-x-1)/2));

            for (auto &it:s) it^=1;
        }

        cout<<fin<<endl;
    }
};

// 长度为5e5的括号字符串，删除k个元素后保持平衡，计数k最小时的删除方式
struct g_22_1{
    static const ll MOD=998244353; vector<int> v;
    const ll mod = (119 << 23) + 1, root = 62; // = 998244353
    void ntt(vector<ll> &a){
        int n = a.size(), L = 31 - __builtin_clz(n);
        static vector<ll> rt(2, 1);
        for (static int k = 2, s = 2; k < n; k *= 2, s++) {
            rt.resize(n);
            ll z[] = {1, qexp(root, mod >> s, mod)};
            rep(i,k,2*k) rt[i] = rt[i / 2] * z[i & 1] % mod;
        }
        vector<int> rev(n);
        rep(i,0,n) rev[i] = (rev[i / 2] | (i & 1) << L) / 2;
        rep(i,0,n) if (i < rev[i]) swap(a[i], a[rev[i]]);
        for (int k = 1; k < n; k *= 2)
            for (int i = 0; i < n; i += 2 * k) rep(j,0,k) {
                    ll z = rt[j + k] * a[i + j + k] % mod, &ai = a[i + j];
                    a[i + j + k] = ai - z + (z > ai ? mod : 0);
                    ai += (ai + z >= mod ? z - mod : z);
                }
    }
    vector<ll> conv(const vector<ll>&a,const vector<ll>&b){
        if(a.empty()||b.empty()) return {};
        int s=a.size()+b.size()-1, B=32-__builtin_clz(s),n=1<<B;
        int inv = qexp(n, MOD - 2, MOD);
        vector<ll> L(a), R(b), out(n);
        L.resize(n), R.resize(n);
        ntt(L), ntt(R);
        rep(i,0,n) out[-i & (n - 1)] = (ll)L[i] * R[i] % MOD * inv % MOD;
        ntt(out);
        return {out.begin(), out.begin() + s};
    }
    ll nCk(int i,int j){
        if(i<j) return 0;
        return fac[i]*ifac[j]%MOD*ifac[i-j]%MOD;
    }
    vector<ll> solve(int l,int r,vector<ll> poly){
        if(poly.empty()) return poly;
        if(l==r){
            poly=conv(poly,{1,1});
            poly.erase(poly.begin(),poly.begin()+v[l]);
            return poly;
        }
        ll m=l+r>>1; ll num=0; rep(x,l,r+1)num+=v[x]; num=min(num,(ll)poly.size());

        vector<ll> small(poly.begin(),poly.begin()+num);
        poly.erase(poly.begin(),poly.begin()+num);

        vector<ll> mul;
        rep(x,0,r-l+2) mul.push_back(nCk(r-l+1,x));
        poly=conv(poly,mul);

        small=solve(m+1,r,solve(l,m,small));
        poly.resize(max(poly.size(),small.size()));
        rep(x,0,small.size()) poly[x]=(poly[x]+small[x])%MOD;

        return poly;
    }
    int solve(string s){
        if(s=="")return 1; v.clear();
        int mn=0,curr=0;
        for(auto it:s){
            if(it=='(') curr++;
            else{
                curr--;
                if(curr<mn){mn=curr; v.push_back(1);}
                else v.push_back(0);
            }
        }
        return solve(0,v.size()-1,{1})[0];
    }
    ll qexp(ll b,ll p,ll m){
        ll res=1;
        while(p){if(p&1) res=(res*b)%m; b=(b*b)%m; p>>=1;}
        return res;
    }
    ll inv(ll i){return qexp(i,MOD-2,MOD);}
    ll fac[10005],ifac[10005];
    int main(){
        int n; string s; int pref[50005];
        fac[0]=1; rep(x,1,1000005) fac[x]=fac[x-1]*x%MOD;
        ifac[1000004]=inv(fac[1000004]);
        rep(x,1000005,1) ifac[x-1]=ifac[x]*x%MOD;
        cin>>s;n=s.size();pref[0]=0;
        rep(x,0,n)pref[x+1]=pref[x]+(s[x]=='('?1:-1);
        int pos=min_element(pref,pref+n+1)-pref;
        string a=s.substr(0,pos),b=s.substr(pos,n-pos);
        reverse(b.begin(),b.end()); for(auto &it:b) it^=1;
        cout<<solve(a)*solve(b)%MOD<<endl;
    }
};

// 统计长度为 3e5 的平衡全排列数 相邻元素 差值小于等于1
struct e_22_8{
    static const int MAXN = 300005;

/* PARTS OF CODE for fft taken from https://cp-algorithms.com/algebra/fft.html */
    const ll mod = 998244353;
    const ll root = 15311432; // which is basically 3 ^ 119
    const ll root_1 = 469870224;
    const ll root_pw = (1 << 23);

    ll fact[MAXN + 1], ifact[MAXN + 1], sum_pow[MAXN + 1];
//    vector<ll> P(MAXN); // this will be the first few terms of e^(x + (x^2)/2).
    vector<ll> P;

    ll fxp(ll a, ll n){ // returns a ^ n modulo mod in O(log(mod)) time
        if(!n){
            return 1;
        }else if(n & 1){
            return a * fxp(a, n ^ 1) % mod;
        }else{
            ll v = fxp(a, n >> 1);
            return v * v % mod;
        }
    }

    inline ll inverse(ll a){ // returns the modular inverse of
        return fxp(a % mod, mod -2);
    }

    void init_fact(){ // initializes fact[ ] and ifact[ ]
        fact[0] = ifact[0] = 1;
        for(int i = 1; i <= MAXN; ++i){
            fact[i] = fact[i - 1]  * i% mod;
            ifact[i] = inverse(fact[i]);
        }
    }

    ll C(ll n, ll r){ // returns nCr in O(1) time
        return (r > n || r < 0) ? 0 : (ifact[r] * ifact[n - r] % mod * fact[n] % mod);
    }

// code for fft in O(nlogn)
    void fft(vector<ll>& a, bool invert){
        int n = a.size();

        /// this does the bit inversion
        for(int i = 1, j = 0; i < n; ++i){
            int bit = n >> 1;
            for(; j & bit; bit >>= 1){
                j ^= bit;
            }
            j ^= bit;
            if(i < j){
                swap(a[i], a[j]);
            }
        }

        for(int len = 2; len <= n; len <<= 1){
            ll wlen = invert ? root_1: root;
            for(int i = len; i < root_pw; i <<= 1){
                wlen = wlen * wlen % mod;
            }
            for(int i = 0; i < n; i += len){
                ll w = 1;
                for(int j = 0; j < len / 2; ++j){
                    ll u = a[i + j], v = a[i + j + len / 2] * w % mod;
                    a[i + j] = u + v < mod ? u + v : u + v - mod;
                    a[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod;
                    w = w * wlen % mod;
                }
            }
        }

        if(invert){
            ll n_1 = inverse(n);
            for(ll& x : a){
                x = x * n_1 % mod;
            }
        }
    }

//multiplying two polynomials a and b using ntt in O(max(A, B)log(max(A, B))), where A, B are degrees of a, b respectively
    vector<ll> mul(vector<ll> const& a, vector<ll> const& b){

        vector<ll> fa(a.begin(), a.end()), fb(b.begin(), b.end());
        int n = 1;
        while(n < (int)a.size() + (int)b.size()){
            n <<= 1;
        }
        fa.resize(n);
        fb.resize(n);

        fft(fa, false);
        fft(fb, false);
        for(int i = 0; i < n; ++i){
            fa[i] = fa[i] * fb[i] % mod;
        }
        fft(fa, true);
        while(fa.size() > 1 && fa[fa.size() - 1] == 0){
            fa.pop_back();
        }

        return fa;
    }

/* End of FFT Template */

    inline void init(){ // precomputes the first few terms of P(x) = e^(x + (x ^ 2) / 2)
        init_fact();
        vector<ll> e_x(MAXN), e_x2_by2(MAXN);
        ll modular_inverse_of_2 = (mod + 1) / 2;

        for(int i = 0; i < MAXN; ++i){
            e_x[i] = ifact[i]; // e^x = sum{x^k / k!}
            e_x2_by2[i] = ((i & 1)) ? 0 : ifact[i / 2] * fxp(modular_inverse_of_2, i / 2) % mod; // e^((x^2)/2) = sum{(x^2k)/(k!.(2^k))}
        }

        P = mul(e_x, e_x2_by2); // P(x) = e^(x + (x ^ 2) / 2) = (e ^ x) . (e ^ ((x ^ 2) / 2))
    }

    void test_case(){

        int N;
        cin >> N;

        ll ans = 0;
        for(int s = 0; s <= N / 4; ++s){ // computing the answer for N using the precomputed P(x) polynomial
            ans = (ans + fact[N - 2 * s] * ifact[s] % mod * P[N - 4 * s]) % mod;
        }

        cout << ans << '\n';
    }

    signed main(){

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        init();
        int test_case_number;
        cin>>test_case_number;
        while(test_case_number--)
            test_case();

        return 0;
    }
};

// 长度为2e5 的两个数字字符串转化a转化使得b为a的子串， 记录操作方式
struct g_22_9{
    static const int M1=998244353,M2=1004535809,M3=469762049,E=524288,N=200005;
    struct poly_{
        const int M;
        poly_(int _M):M(_M){}
        int R[N*4];
        long long qpow(long long a,long long b){
            long long ans=1;
            while(b){
                if(b&1)
                    ans=ans*a%M;
                a=a*a%M;
                b>>=1;
            }
            return ans;
        }
        long long wn[N*4],iwn[N*4],inv[N*4],fac[N*4],ifac[N*4];
        void init(int E,int g){
            int i;
            iwn[E/2]=wn[E/2]=1;
            long long s1=qpow(g,(M-1)/E);
            long long s2=qpow(s1,M-2);
            for(i=E/2+1;i<E;++i){
                wn[i]=wn[i-1]*s1%M;
                iwn[i]=iwn[i-1]*s2%M;
            }
            for(i=E/2-1;i;--i){
                wn[i]=wn[i<<1];
                iwn[i]=iwn[i<<1];
            }
            ifac[0]=fac[0]=inv[1]=1;
            for(i=2;i<E;++i)
                inv[i]=inv[M%i]*(M-M/i)%M;
            for(i=1;i<E;++i){
                ifac[i]=inv[i]*ifac[i-1]%M;
                fac[i]=fac[i-1]*i%M;
            }
        }
        unsigned long long ccc[N*4];
        void NTT(long long *f,int lim,int op){
            int i,j,k;
            for(i=0;i<lim;++i){
                R[i]=(R[i>>1]>>1)|(i&1?lim>>1:0);
                if(R[i]<i)
                    swap(f[R[i]],f[i]);
            }
            for(i=0;i<lim;++i)
                ccc[i]=(f[i]%M+M)%M;
            for(i=1;i<lim;i<<=1)
                for(j=0;j<lim;j+=(i<<1))
                    for(k=j;k<j+i;++k){
                        long long w=(op==1?wn[k-j+i]:iwn[k-j+i]);
                        unsigned long long p=ccc[k+i]*w%M;
                        ccc[k+i]=ccc[k]+M-p;
                        ccc[k]+=p;
                    }
            for(i=0;i<lim;++i)
                f[i]=ccc[i]%M;
            if(op==-1){
                long long inv=qpow(lim,M-2);
                for(i=0;i<lim;++i)
                    f[i]=f[i]*inv%M;
            }
        }
        long long ta[N*4],tb[N*4];
        void mult(long long *a,int n,long long *b,int m,long long *c){
            int lim=1;
            while(lim<n+m)
                lim<<=1;
            copy(a,a+n,ta);
            copy(b,b+m,tb);
            for(int i=n;i<lim;++i)
                ta[i]=0;
            for(int i=m;i<lim;++i)
                tb[i]=0;
            NTT(ta,lim,1);
            NTT(tb,lim,1);
            for(int i=0;i<lim;++i)
                ta[i]=ta[i]*tb[i]%M;
            NTT(ta,lim,-1);
            copy(ta,ta+lim,c);
        }
    }X(M1),Y(M2),Z(M3);
    int n,m,o[N],t,tn;
    long long a[N],b[N],c[N],d[N*4],e[N],f[N*4],ss[N],td[N],tf[N];
    bool fl[N],zz;
    vector<int> ans;
    long long cal(int l,int r){
        return 1ll*(l+r)*(r-l+1)/2;
    }
    long long cal2(int u,int v){
        return 1ll*((v-u)/2+1)*(u+v)/2;
    }
    bool iok(int n,int p,int q){
        long long ss=q+1ll*(n/2)*(n/2+1);
        p=p+(n/2+1);
        long long mn=cal(0,p-1),mx=cal(n-p+1,n);
        if(mn<=ss&&ss<=mx){
            for(int i=n;i<n+m-2;++i)
                if(td[i]!=tf[i-n+1]&&td[i]!=tf[i-n+1]-1)
                    return false;
            ss-=mn;
            for(int i=n;i<n+m-2;++i)
                if(td[i]!=tf[i-n+1])
                    ans.push_back(i+2);
            fill(fl,fl+1+n,0);
            for(int i=0;i<p;++i)
                fl[(ss/p+(i>=p-ss%p)+i)]=1;
            for(int i=0;i<=n;++i)
                if(fl[i]^(i&1)^1)
                    if(n+1-i<=tn)
                        ans.push_back(n+1-i);
            zz=true;
            return true;
        }
        return false;
    }
    void OT(){
        if(!zz)
            puts("-1");
        else{
            printf("%d\n",ans.size());
            for(auto it:ans)
                printf("%d ",it);
            printf("\n");
        }
    }
    void judgement(poly_ &v,long long *c,long long *e){
        for(int i=0;i<n-2;++i)
            d[i]=(c[i+1]+c[i+2])%v.M;
        for(int i=0;i<m-2;++i)
            f[i]=(e[i+1]+e[i+2])%v.M;
        reverse(f,f+m-2);
        long long s=0;
        for(int i=0;i<m-2;++i)
            s+=(f[i]*f[i]-f[i])%v.M;
        for(int i=1;i<=n-2;++i)
            ss[i]=(ss[i-1]+d[i-1]*(d[i-1]+1))%v.M;
        v.mult(d,n-2,f,m-2,d);
        for(int i=m-3;i<n-2;++i)
            if((s+ss[i+1]-ss[i-m+3]-2*d[i])%v.M!=0)
                o[i-m+4]=0;
    }
    int main(){
        X.init(E,3);
        Y.init(E,3);
        Z.init(E,3);
        scanf("%d",&t);
        while(t--){
            scanf("%d",&n);
            tn=n;
            for(int i=1;i<=n;++i)
                scanf("%lld",&a[i]);
            scanf("%d",&m);
            for(int i=1;i<=m;++i)
                scanf("%lld",&b[i]);
            for(int i=1;i<n;++i)
                c[i]=a[i]+a[i+1];
            for(int i=1;i<m;++i)
                e[i]=b[i]+b[i+1];
            fill(o,o+1+n,0);
            ans.clear();
            for(int i=1;i<=n;++i)
                o[i]=1;
            if(m>2){
                for(int i=0;i<n-2;++i)
                    td[i+1]=c[i+1]+c[i+2];
                for(int i=0;i<m-2;++i)
                    tf[i+1]=e[i+1]+e[i+2];
                judgement(X,c,e);
                judgement(Y,c,e);
                judgement(Z,c,e);
            }
            else
                for(int i=1;i<=n;++i)
                    o[i]=1;
            int x=-1;
            zz=false;
            if(m==1){
                for(int i=1;i<=n;++i)
                    if(-cal2(0,i/2*2)<=b[1]-a[i]&&b[1]-a[i]<=cal2(1,(i-1)/2*2+1)){
                        for(int j=-(i/2+1);j<=(i+1)/2;++j)
                            if(iok(i,j,b[1]-a[i]))
                                break;
                        break;
                    }
            }
            else
                for(int i=1;i+m-1<=n;++i)
                    if(o[i]&&iok(i,(a[i]+a[i+1])-(b[1]+b[2]),b[1]-a[i]))
                        break;
            OT();
        }
    }
};

signed main(){
//    g_24_6 g;g.main();

    i_24_9 i;i.main();
}